package com.tedu.net;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

//客户端
public class Test_Client {
    public static void main(String[] args) throws Exception {
        //连接指定服务器
        //本机IP： 127.0.0.1
        //实际则学服务器IP
        Socket socket = new Socket("127.0.0.1",7777);
        System.out.println("连接成功...");
        //开始通信
        OutputStream out = socket.getOutputStream();
        String txt = new Scanner(System.in).next();
        out.write(txt.getBytes());
        out.flush();

        InputStream in = socket.getInputStream();
        for (int i = 0; i < 5; i++) {
            char tx = (char) in.read();
            System.out.print(tx);
        }
    }
}
